<%@page import="uniwill.user.UserManagerSpringHelper"%>
<%@page import="uniwill.user.exception.PasswordMismatchException"%>
<%@page import="uniwill.user.exception.UserNotFoundException"%>
<%@page import="java.sql.SQLException"%>
<%@page import="uniwill.user.UserManager"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
	pageEncoding="EUC-KR"%>
<%

	String userId = request.getParameter("userId");
	String password = request.getParameter("password");
	if(userId==null || password==null){
		response.sendRedirect("error_message.jsp");
		return;
	}
	
	UserManager manager=
			UserManagerSpringHelper.getUserManager(getServletContext());
	try {
		manager.login(userId, password);
		session.setAttribute("userId", userId);
		response.sendRedirect("user_list.jsp");
	} catch (SQLException e) {
		e.printStackTrace();
		String msg=e.getMessage();	
		out.println("<script>");
		out.println("alert('"+msg+"');");
		out.println("location.href='user_login.jsp';");
		out.println("</script>");
	} catch (UserNotFoundException e) {
		String msg=e.getMessage();	
		out.println("<script>");
		out.println("alert('"+msg+"');");
		out.println("location.href='user_login.jsp';");
		out.println("</script>");
	} catch (PasswordMismatchException e) {
		String msg=e.getMessage();	
		out.println("<script>");
		out.println("alert('"+msg+"');");
		out.println("location.href='user_login.jsp?userId="+userId+"';");
		out.println("</script>");
	}
%>













